package com.elinkway.infinitemovies.http.requesttask;

import android.content.Context;

import com.elinkway.infinitemovies.async.MoviesHttpAsyncTask;
import com.elinkway.infinitemovies.async.RequestResultListener;
import com.elinkway.infinitemovies.bean.ReportSubmitBean;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.ReportSubmitParser;
import com.lvideo.http.bean.LVideoDataHull;

/**
 * Created by huangxiaojian on 2017/8/4.
 *
 */

public class SubmitFeedbackQuestionTask extends MoviesHttpAsyncTask<ReportSubmitBean> {

    private RequestResultListener<ReportSubmitBean> mListener;

    private Context mContext;
    private String mCity;
    private String mScope;
    private String mSubscope;
    private String mAid;
    private String mSite;
    private String mContact;
    private String mDescription;

    public SubmitFeedbackQuestionTask(Context context, String aid, String site, String city, String scope,
                                      String subscope, String description, String contact) {
        super(context);
        mContext = context;
        mAid = aid;
        mScope = scope;
        mSite = site;
        mContact = contact;
        mDescription = description;
        mCity = city;
        mSubscope = subscope;
    }

    @Override
    public void netNull() {
        super.netNull();
        if(null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        super.netErr(updateId, errMsg);
        if(null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void dataNull(int updateId, String errMsg) {
        super.dataNull(updateId, errMsg);
        if(null != mListener) {
            mListener.onRequestFailed();
        }
    }


    @Override
    public LVideoDataHull<ReportSubmitBean> doInBackground() {
        LVideoDataHull<ReportSubmitBean> ret = MoviesHttpApi.requestFeedbackQuestionSubmit(
                new ReportSubmitParser(), mAid, mSite, mCity, mScope, mSubscope, mDescription, mContact);
        return ret;
    }

    @Override
    public void onPostExecute(int updateId, ReportSubmitBean result) {
        if(null != mListener) {
            mListener.onRequestSuccess(updateId, result);
        }
    }

    public void setListener(RequestResultListener<ReportSubmitBean> mListener) {
        this.mListener = mListener;
    }
}
